<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Model_stasiun extends CI_Model {
	
	var $table_name = "stasiun";
	
	function __construct()
	{
		parent::__construct();
	}
	
	function get_all()
	{
		$this->db->order_by("Nama_Stasiun", "asc"); 
		$query = $this->db->get($this->table_name);
		return $query->result();
	}
	
	function get_one($id)
	{
		$this->db->from($this->table_name)->where('id',$id);
		$query = $this->db->get();
		return $query->result();
	}
	
	function posisi_tengah()
	{
		$this->db->select_avg('lat');
		$this->db->select_avg('lng');
		$query = $this->db->get($this->table_name);
		return $query->result();
	}
	
	function remove($id)
	{
		$this->db->delete($this->table_name)->where('id',$id);
	}
	
	function insert($nama,$kode,$alamat,$lat,$lng)
	{
		//$this-db->
	}
}
